package com.linxianqin.log.manager;

import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
import org.springframework.stereotype.Component;

import javax.annotation.PreDestroy;

/**
 * 功能描述：确保应用退出时能关闭后台线程
 * @author 林贤钦
 * @version 1.00
 * @Date 2020/12/8
 */
@Component
public class ShutdownManager {
    private final static Log logger = LogFactory.getLog(ShutdownManager.class);
    @PreDestroy
    public void destroy()
    {
        shutdownAsyncManager();
    }
    /**
     * 停止异步执行任务
     */
    private void shutdownAsyncManager()
    {
        try
        {
            logger.info("====关闭后台任务任务线程池====");
            AsyncManager.me().shutdown();
        }
        catch (Exception e)
        {
            logger.error(e.getMessage(), e);
        }
    }
}
